package com.leapp.sk.viewdelegate.find

import android.content.Context
import android.support.v7.app.AppCompatActivity
import android.text.TextUtils
import com.example.mvp.delegate.BaseAppDelegate
import com.example.mvp.view.NoScrollGridView
import com.example.mvp.view.SKTopBar
import com.leapp.sk.R
import com.leapp.sk.bean.AuditionsEntity
import com.leapp.sk.bean.ChildcareEducationEntity
import com.leapp.sk.ui.adapter.AuditionsAdapter
import com.leapp.sk.ui.adapter.ChildcareEducationAdapter

/**
 * 育儿教育视图托管类
 * @author  chaohaipeng  on 2018/8/15.
 */
class ChildcareEducationDelegate : BaseAppDelegate(){
    override fun initWidget() {
    }

    override fun initLayoutRes(): Int {
        return R.layout.activity_childcare_education
    }

    /**
     * 初始化适配器
     */
    fun initAdapter(context: Context, mlist: List<ChildcareEducationEntity>){
        val gv_ace_child_Grid = getView<NoScrollGridView>(R.id.gv_ace_child_Grid)
        val auditionsAdapter= ChildcareEducationAdapter(context, mlist)
        gv_ace_child_Grid.adapter=auditionsAdapter
    }

    /**
     * 设置标题栏
     */
    fun setTitle(title:String?){
        val jtb_ace_child= getView<SKTopBar>(R.id.jtb_ace_child)
        if (!TextUtils.isEmpty(title)){
            jtb_ace_child.setTitle(title)
        }
        setEvent(jtb_ace_child)
    }

    /**
     * 设置设置事件
     */
    fun setEvent(topBar: SKTopBar){
        topBar?.inVisibleLine()
        topBar?.setEventInterface(object : SKTopBar.EventInterface{
            override fun leftOnClick() {
                getActivity<AppCompatActivity>().finish()

            }
            override fun rightOnClick() {
            }

        })
    }
}